export default {
    get(key) {
        try {
            return JSON.parse(localStorage.getItem(key))
        } catch (err) {
            if (!navigator.cookieEnabled) {
                alert('请您打开浏览器的cookie读写功能')
            }
            return localStorage.getItem(key)
        }
    },
    set(key, val) {
        try {
            if (!navigator.cookieEnabled) {
                alert('请您打开浏览器的cookie读写功能')
            }
            localStorage.setItem(key, JSON.stringify(val))
        } catch (error) {
            localStorage.setItem(key, val)
        }
    }
}
